//
//  SearchCollectionViewCell.m
//  准到-ipad
//
//  Created by zhundao on 2017/9/8.
//  Copyright © 2017年 zhundao. All rights reserved.
//

#import "LessonResultItemCell.h"

@interface LessonResultItemCell ()
@property (nonatomic,strong)UIButton *coverBtn;
@property (nonatomic,strong)UILabel *attLabel;

@property (nonatomic,strong)LessonSearchModel *model;
@property (nonatomic,assign)NSInteger index;
@end

@implementation LessonResultItemCell

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {

        _attLabel = [[UILabel alloc] init];
        _attLabel.textAlignment = NSTextAlignmentCenter;
        _attLabel.font = font(14);
        [self.contentView addSubview:_attLabel];
        _attLabel.layer.cornerRadius = 15;
        _attLabel.layer.masksToBounds = YES;
        [_attLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.bottom.equalTo(self.contentView);
        }];
        _attLabel.text = @"测试";
        _attLabel.backgroundColor = RGBA(248, 248,248, 1);
        
        _coverBtn = [[UIButton alloc]init];
        [_coverBtn addTarget:self action:@selector(coverMethod) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_coverBtn];
        
        [_coverBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.bottom.equalTo(self.contentView);
        }];
        
    }
    return self;
}

- (void)setSearchModel:(LessonSearchModel *)model atIndex:(NSInteger)index{
    self.model = model;
    self.index = index;
    self.attLabel.text = model.word;
}

- (void)coverMethod{
    if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectedWithCurrentModel:atIndex:)]) {
        [self.delegate didSelectedWithCurrentModel:self.model atIndex:self.index];
    }
}


@end
